package com.example.feignservicea.controller;

import com.example.feignservicea.config.DataConfigProperties;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api("userController相关api")
public class UserController {


    @Autowired
    private DataConfigProperties dataConfigProperties;


    @ApiOperation("获取数据库信息")
    @ApiResponses({
            @ApiResponse(code = 400, message = "请求参数没填好"),
            @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")
    })
    @RequestMapping(value = "/getDataConfigProperties", method = RequestMethod.GET)
    public DataConfigProperties getDataConfigProperties() throws InterruptedException {
        //Thread.sleep(4000);
        DataConfigProperties newConfig = new DataConfigProperties();
        BeanUtils.copyProperties(dataConfigProperties, newConfig);
        newConfig.setUsername(newConfig.getUsername().concat("a service"));
        return newConfig;
    }


}